package com.zhenti.z1;


/**
 * @Author jsh
 * @Date 2023/3/4 21:48
 * @Version 1.0
 *
 * 超级回文数
 * 回文数为对称数如（1，1221，88，898）
 *
 */
public class zhenti_p13 {

    public static void main(String[] args) {

        System.out.println(isInwrap(3));
        /*Integer i0 = 11211;
        System.out.println(isInwrap(11121111));
        System.out.println("[11]".split("\\[")[1]);*/
        findSubStringInwraproundString("[4,1000]");
    }

    public static void findSubStringInwraproundString(String patten){

        String[] split = patten.split(",");
        int x = Integer.parseInt(split[0].split("\\[")[1]);
        int y = Integer.parseInt(split[1].split("\\]")[0]);

        double sqrt = Math.sqrt(y);

        int num = 0;

        for (int i = 0; i <= y; i++) {
            if (i * i >y ){System.out.println(i * i);
                break;
            }
            if (isInwrap(i) && isInwrap(i *i) && i * i >= x){
                System.out.println(i * i);
                num++;
            }
        }

        System.out.println(num);


    }

    //判断是否为回文数
    public static boolean  isInwrap(Integer patten){

        char[] charArray = String.valueOf(patten).toCharArray();
        int l =   charArray.length;
        for (int i = 0; i < charArray.length; i++) {
            if (charArray[i] != charArray[l-i-1]){
                return false;
            }
        }
        return true;
    }

}
